﻿@{
    ViewBag.Title = "人员接口配置";
    Layout = "~/Views/Shared/_Main.cshtml";
}
@section Head{
    <script type="text/javascript">
        $(function () {
            btnSearch_Click();
            $.post('/SysMenu/DBList', function (result) {
                for (var i = 0; i < result.length; i++) {
                    $("#selDBName").append("<option value='" + result[i].DBName + "'>" + result[i].DBName + "</option>");
                }
            });
        });
        var opts = {
            rows: 10,
            height: 450,
            url: "/SysUser/GetUserIFList",
            para: {},
            idField: "GUID",
            checkbox: false,
            columns: [
                    { field: 'ITable', title: '接口表名称', width: 30, sortable: true },
                    { field: 'IContent', title: '表描述', width: 40, sortable: true },
                    { field: 'DBName', title: '实例', width: 10, align: 'center', sortable: true }, 
                    { field: 'CreateTime', title: '创建时间', width: 10, align:'center', sortable: true }, 
                    { field: 'GUID', title: '操作', align: 'center', width: 10,
                        formatter: function (value, rowData, rowIndex) {
                            var doActionOptions = "<select onchange='return DoAction(this.options.selectedIndex,\"" + value + "\")' ><option value=''>-请选择-</option>";
                            doActionOptions += "<option>修改</option><option>删除</option>";
                            return doActionOptions;
                        }
                    }
                    ]
        };

        function btnAdd_Click() {
            AddFun();
        }
        function btnSearch_Click() {
            opts.para["ITable"] = $.trim($("#txtITable").val());
            opts.para["DBName"] = $.trim($("#selDBName").val()); 
            $("#DataGrid").dg(opts);
        }
        //“操作”下拉框事件
        function DoAction(i, value) {
            if (i == 1) {
                // 编辑
                EditFun(value);
            }
            else if (i == 2) {
                // 删除
                DeleteFun(value);
            }
        }

        function AddFun() {
            window.location.href = "/SysUser/EditUserIF"; 
        }

        function EditFun(funID) {
            window.location.href = "/SysUser/EditUserIF?IFID=" + funID;
            
        }
        function DeleteFun(funID) {
            if (confirm("确定要删除吗?")) {
                $.post("/SysUser/DeleteUserIF?IFID=" + funID, function (res) {
                    if (result.Success == true) {
                        alert(result.Message);
                    }
                    else {
                        alert(result.Message);
                    }
                    InitList();
                });
            }
        }
    </script>
}
<div style="margin: 5px;">
    <table class="listTitle">
        <tr>
            <td width="15">
                <img src="/images/search.png" />
            </td>
            <td width="300">
                人员接口配置搜索
            </td>
            <td align="right">
            </td>
        </tr>
    </table>
    <table class="searchArea" width="100%">
        <tr>
            <td>
                 接口表名称：
                <input id="txtITable" type="text" class="inputSearch" style="width: 120px;" />  
                实例：
                <select id="selDBName">
                <option value="">-请选择-</option>
                </select>
                <input id="btnSearch" type="button" value=" 搜 索 " onclick="btnSearch_Click()" />
            </td>
        </tr>
    </table>
    @{
        // 渲染输出列表
        var dataGrid = new ViewDataDictionary();
        dataGrid.Add("PanelTitle", "人员接口配置列表");
        dataGrid.Add("GridID", "DataGrid");
        dataGrid.Add("ShowAddButton", true);
        dataGrid.Add("ShowDeleteButton", false);
        dataGrid.Add("ShowOtherButton", false);
        dataGrid.Add("OtherButtonID", "btnView");
        dataGrid.Add("OtherButtonValue", "查 看");
        dataGrid.Add("OtherButtonClick", "btnView_Click()");
        dataGrid.Add("ShowBackButton", false);
        dataGrid.Add("ShowCloseButton", false);
        dataGrid.Add("ShowPager", true);
        dataGrid.Add("ShowLoading", true);
        @Html.Partial("_GridPanel", dataGrid);
    }
</div>
